﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;

public partial class admin_Mail_List : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      if (!IsPostBack)
      {
        ShowData();
      }
    }

    private void ShowData()
    {
      EmailBLL data = new EmailBLL();
      GridView1.DataSource = data.GetAll();
      GridView1.DataBind();
    }
    protected void btnExport_Click(object sender, EventArgs e)
    {
    Response.AddHeader("content-disposition", "attachment;filename=Danh-sach-dang-ky-nhan-email.xls");
    Response.Charset = String.Empty;
    Response.ContentType = "application/vnd.xls";
 
    var sw = new System.IO.StringWriter();
    var hw = new HtmlTextWriter(sw);
    GridView1.RenderControl(hw);
 
    Response.Write(sw.ToString());
    Response.End();
    }

    public override void VerifyRenderingInServerForm(Control control)
    {
    }  

}